﻿Imports Alquilaqi
Public Class ModificarInmueble

    Public modificarform As InmuebleModificar

    Private Sub Foto1bt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Foto1bt.Click
        OpenFileDialog1.ShowDialog()
        foto1T.Text = OpenFileDialog1.FileName
    End Sub

    Private Sub Foto2bt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Foto2bt.Click
        OpenFileDialog2.ShowDialog()
        foto2T.Text = OpenFileDialog2.FileName
    End Sub

    Private Sub guardarbt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guardarbt.Click

        Dim negocio As New InmuebleNegocio

        Try
            negocio.actualizar(idlabel.Text, Me.precioT.Text, Me.foto1T.Text, Me.foto2T.Text, Me.estadoCB.Text, Me.valorT.Text)

            Me.modificarform.dginmueble.DataSource = ""
            Me.Close()
        Catch ex As Exception
            mensaje.Text = "Hubo un error al guardar"
        End Try
    End Sub



    'End Sub

    Private Sub ModificarInmueble_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If idlabel.Text <> "" Then
            Dim negocio As New InmuebleNegocio
            Dim modelo = negocio.obtener(idlabel.Text)
            precioT.Text = modelo.Precio
            foto1T.Text = modelo.Foto1
            foto2T.Text = modelo.Foto2
            estadoCB.Text = modelo.Estado
            valorT.Text = modelo.Valoracion
        End If
    End Sub
End Class